<?php 
 class ShopModel extends Model{
 	public $table='shop';

 	public $validate = array(
 		array('shopname','nonull','菜单名不能为空',2,3),
 		array('shopname','maxlen:20','菜单名最大长度不能超过20个',2,3),
 		
 		array('price','nonull','商品价格不能为空',2,3)
 		);


 		public function add_data($where=NULL){
 			$this->where($where)->add();
 		}


 		public function update_data($where){
 			$this->where($where)->save();
 		}


 		public function del_data($where){
 			$this->where($where)->delete();
 		}


 		public function get_data($where=NULL){
 			return $this->where($where)->all();
 		}

 		public function in_data($where=null){
 			return $this->in($where)->all();
 		}

 		public function get_one_data($where=NULL){
 			return $this->where($where)->find();
 		}


 		public function add_shop(){
 			$up = new Upload($path = 'upload/shop');
 			$upload = $up->upload();

 			if(empty($upload)){
 				$this->error = $up->error;	

 				return false;

 			}

 			$upload = current($upload);

 			$this->data['img'] = $upload['path'];

 			$aid = $this->add();

			return true;

 		}

 }






 ?>